#pragma once

#ifndef _CORE_PACKAGE_LABELS_H_
#define _CORE_PACKAGE_LABELS_H_

#error this package has been deprecated, use "Package.h" instead.

#include <string>
#include "Poco\Net\SocketStream.h"

namespace ExamSystem
{

#define DeclareProtocolString(x) static const std::string x

    using Poco::Net::SocketOutputStream;
    /**************************************************************************\
     Component:     CExamProtocol
     Description:
        this class provides several methods that create packages according to 
        the protocol
    \**************************************************************************/
    class CExamProtocol
    {
    protected:
        CExamProtocol(void);

    public:
        // start and end stream
        static SocketOutputStream &SendStreamStartLabel(SocketOutputStream &stream);
        static SocketOutputStream &SendStreamEndLabel(SocketOutputStream &stream);


        // keep alive package and its reply
        static SocketOutputStream &SendKeepAlivePackage(SocketOutputStream &stream);
        static SocketOutputStream &SendKeepAliveReplyPackage(SocketOutputStream &stream);

        // identity:
        enum Identity { Server, Client };
        static SocketOutputStream &SendIdentityPackage(SocketOutputStream &stream, Identity identity);

        // versionType: 1 - system, 2 database
        // when versionType == 1, versionValue doesn't used
        enum VersionType { SystemVersion, DatabaseVersion };
        static SocketOutputStream &SendVersionPackage(SocketOutputStream &stream, VersionType versionType, const std::string &versionValue = nullString);

        // send the result of version check
        static SocketOutputStream &SendVersionCheckPackage(SocketOutputStream &stream, bool passed);

        // send the database file
        static SocketOutputStream &SendDatabasePackage(SocketOutputStream &stream, const std::string &databaseFile);

        // send the result of receiving
        static SocketOutputStream &SendReceivingResultPackage(SocketOutputStream &stream, bool passed);
        
        // send exam order
        enum ExamOrder { OrderStartExam, OrderEndExam };
        static SocketOutputStream &SendExamOrderPackage(SocketOutputStream &stream, ExamOrder order);

        // send exam message
        enum MessageType { MessageInformation, MessageAlert };
        static SocketOutputStream &SendExamMessagePackage(SocketOutputStream &stream, MessageType type, const std::string &message);

    public:
        // this file define some labels
        DeclareProtocolString(namespaceURI);
        DeclareProtocolString(systemVersion);

        // labels
        DeclareProtocolString(labelExamination);
        DeclareProtocolString(labelPackage);
        DeclareProtocolString(labelIdentity);
        DeclareProtocolString(labelVersion);
        DeclareProtocolString(labelFile);
        DeclareProtocolString(labelMessage);
        DeclareProtocolString(labelQuestion);

        // capsuled labels
        DeclareProtocolString(capsuledLabelExamination);
        DeclareProtocolString(capsuledLabelExaminationEnd);

        // attributes
        DeclareProtocolString(attributeType);
        DeclareProtocolString(attributeIdentity);
        DeclareProtocolString(attributeVersion);
        DeclareProtocolString(attributeResult);
        DeclareProtocolString(attributeValue);
        DeclareProtocolString(attributeName);
        DeclareProtocolString(attributeSize);
        DeclareProtocolString(attributeMd5);
        DeclareProtocolString(attributeOrder);
        DeclareProtocolString(attributeRandomQuestion);
        DeclareProtocolString(attributeExamTime);
        DeclareProtocolString(attributeNumber);


        // types
        DeclareProtocolString(typeHold);
        DeclareProtocolString(typeHoldReply);
        DeclareProtocolString(typeIdentity);
        DeclareProtocolString(typeSystemVersion);
        DeclareProtocolString(typeVersion);
        DeclareProtocolString(typeVersionCheck);
        DeclareProtocolString(typeDatabase);
        DeclareProtocolString(typeReceivingResult);
        DeclareProtocolString(typeExamOrder);
        DeclareProtocolString(typeExamMessage);
        DeclareProtocolString(typeExamInformation);

        // values
        DeclareProtocolString(valueServer);
        DeclareProtocolString(valueClient);
        DeclareProtocolString(valueOk);
        DeclareProtocolString(valuePassed);
        DeclareProtocolString(valueFailed);
        DeclareProtocolString(valueSystem);
        DeclareProtocolString(valueDatabase);
        DeclareProtocolString(valueExamStart);
        DeclareProtocolString(valueExamEnd);
        DeclareProtocolString(valueInfo);
        DeclareProtocolString(valueAlert);

    protected:
        // packages
        DeclareProtocolString(packageKeepAlive);
        DeclareProtocolString(packageKeepAliveReply);

        DeclareProtocolString(packageStart);
        DeclareProtocolString(LabelOneLineEnd);
        DeclareProtocolString(packageEnd);

        DeclareProtocolString(nullString);
    };


}


#endif